%include "exception.i"

%ignore bb_host_connect(bb_host_t **pButler,const char* addr,int port);
%ignore bb_host_disconnect(bb_host_t *ppButler);

%exception bb_host_t {
  $action
  if (!result) {
    PyErr_SetString(PyExc_IOError, "can't connect to remote");
    SWIG_fail;
  }
}

struct bb_host_t {};
%extend bb_host_t {
  bb_host_t(const char* addr,int port) {
    bb_host_t *pButler = 0;
    bb_host_connect(&pButler, addr, port);
    return pButler;
  }
  ~bb_host_t() {
     bb_host_disconnect($self);
   }
}
